# Contributor: Patrycja Rosa <alpine@ptrcnull.me>
# Maintainer: Patrycja Rosa <alpine@ptrcnull.me>
pkgname=conduit
pkgver=0.6.0
pkgrel=1
pkgdesc="Simple, fast and reliable chat server powered by Matrix"
url="https://conduit.rs/"
# ring-rs
arch="all !riscv64 !ppc64le !s390x"
license="Apache-2.0"
makedepends="cargo sqlite-dev cargo-auditable clang17-libclang rocksdb-dev snappy-dev"
install="$pkgname.pre-install"
subpackages="$pkgname-openrc"
source="https://gitlab.com/famedly/conduit/-/archive/v$pkgver/conduit-v$pkgver.tar.gz
	system-sqlite.patch

	conduit.toml
	conduit.initd
	conduit.confd
	"
builddir="$srcdir/conduit-v$pkgver"
options="net"

_features="--no-default-features --features=conduit_bin,backend_sqlite,backend_rocksdb"

export ROCKSDB_LIB_DIR="/usr/lib/"
export SNAPPY_LIB_DIR="/usr/lib/"

prepare() {
	default_prepare
	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --release --frozen $_features
}

check() {
	cargo test --frozen $_features
}

package() {
	install -Dm755 target/release/conduit -t "$pkgdir"/usr/bin
	install -Dm755 "$srcdir"/conduit.initd "$pkgdir"/etc/init.d/conduit
	install -Dm644 "$srcdir"/conduit.confd "$pkgdir"/etc/conf.d/conduit
	install -Dm644 "$srcdir"/conduit.toml "$pkgdir"/etc/conduit/conduit.toml
}

sha512sums="
a8267f59ef829a7d3e6f528c9b4487993c7d3c930d6849254c3acf6547b041bceb5435572d937c7b98456f0379673c468528ff49ba5a6bef7590679ab9077c32  conduit-v0.6.0.tar.gz
7bc072043ebedd74ff8805c8b478ecc35f42e81a53d6b2c13d9d8568ad27b64b992d4a9bab9a6ced253971bbd4922f4da814cf2decdf253a2f5a078ced55f834  system-sqlite.patch
9b77f8934f79215a98c41a859c2b875fd9ee7b618c84316b6be849cb0998ceebcbb3dcbb9b834bda74c32d46722140c3320abd8744c59fe2023fb273c29edc5f  conduit.toml
be411bc3447d684c546249e6fe6573d1c7798c7dfc148564b00b60026592eafa66dec4289a2d336656291ba1b915dd8b1e4df632de44a0ec0b3ad7d971ab062f  conduit.initd
8769e2feb4e0db08d7c6861a9d9110db8b846a496086f697080fda7270c97b506cbb10326cf708cdeab5eda68ec93a5ad86db4db5b9b0ebc189e6a5cefacf3a1  conduit.confd
"
